using System;
using System.Windows.Forms;

namespace haxeProject {

	public class Dialog {
		
		public static String HX = "haXe Source File (*.hx)|*.hx";
		public static String SWF = "Flash SWF File (*.swf)|*.swf";
		public static String PROJECT = "haXe Project (*.hxp)|*.hxp";
		public static String ALL_FILTER = "|All files (*.*)|*.*";
		
		public static void Message( String msg ) {
			MessageBox.Show(msg,"Message",MessageBoxButtons.OK,MessageBoxIcon.Information);			
		}
		
		public static void Error( String msg ) {
			MessageBox.Show(msg,"Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
		}

		public static bool Confirm( String msg ) {
			return MessageBox.Show(msg,"Please confirm",MessageBoxButtons.YesNo,MessageBoxIcon.Question) == DialogResult.Yes;
		}
		
		public static string[] OpenMultiple( String filter, String basedir ) {
			OpenFileDialog dialog = new OpenFileDialog();
			dialog.Filter = filter + ALL_FILTER;
			dialog.Multiselect = true;
			if( PluginMain.project != null )
				dialog.InitialDirectory = System.IO.Path.GetDirectoryName(PluginMain.project.file);
			if( basedir != null )
				dialog.InitialDirectory += "\\"+basedir;			
			if( dialog.ShowDialog(null) != DialogResult.OK )
				return null;
			return dialog.FileNames;
		}

		public static String Open( String filter ) {
			OpenFileDialog dialog = new OpenFileDialog();
			dialog.Filter = filter + ALL_FILTER;
			if( PluginMain.project != null )
				dialog.InitialDirectory = System.IO.Path.GetDirectoryName(PluginMain.project.file);			
			if( dialog.ShowDialog(null) != DialogResult.OK )
				return null;
			return dialog.FileName;
		}

		public static String Create( String filter, String basedir ) {
			SaveFileDialog dialog = new SaveFileDialog();
			dialog.Filter = filter + ALL_FILTER;
			if( PluginMain.project != null )
				dialog.InitialDirectory = System.IO.Path.GetDirectoryName(PluginMain.project.file);						
			if( basedir != null )
				dialog.InitialDirectory += "\\"+basedir;			
			if( dialog.ShowDialog(null) != DialogResult.OK )
				return null;
			return dialog.FileName;
		}
		
	}
}
